Matthew Ziegler
2024-03-26
data %>% new_data %>% tables
data %>% different_data %>% figures
dat_cdiff <- read.csv("/Users/mattz/Documents/GitHub/shea24_demo/HAICViz_-_CDI_20240214.csv") %>%
janitor::clean_names() %>%
filter(topic == "Case rates (cases per 100,000)", series == "Community-associated" |
series == "Healthcare-associated")## year_name topic view_by grouping
## 1 2011 Case rates (cases per 100,000) Total Epi Class
## 2 2012 Case rates (cases per 100,000) Total Epi Class
## 3 2013 Case rates (cases per 100,000) Total Epi Class
## 4 2014 Case rates (cases per 100,000) Total Epi Class
## 5 2015 Case rates (cases per 100,000) Total Epi Class
## 6 2016 Case rates (cases per 100,000) Total Epi Class
## series value
## 1 Community-associated 48.16
## 2 Community-associated 52.88
## 3 Community-associated 55.75
## 4 Community-associated 57.83
## 5 Community-associated 65.81
## 6 Community-associated 67.20
dat_cdiff %>%
ggplot(aes(x = as.factor(year_name), y = value, fill = series)) + geom_col(position = "dodge") +
labs(title = "Cases by year", y = "CDI cases per 1000 individuals", x = "Year")dat_cdiff_cat_plot <- read.csv("/Users/mattz/Documents/GitHub/shea24_demo/HAICViz_-_CDI_20240214.csv") %>%
janitor::clean_names() %>%
filter(topic == "Case rates (cases per 100,000)") %>%
mutate(cat = case_when(grepl("HA|CA", series) == TRUE & grepl("years", series) ==
TRUE ~ "age", grepl("Male|Female", series) == TRUE & grepl("HA|CA", series) ==
TRUE ~ "sex", grepl("White|Non-white", series) == TRUE & grepl("HA|CA", series) ==
TRUE ~ "race")) %>%
filter(!is.na(cat)) %>%
separate(series, into = c("category", "group"), sep = " - ") %>%
ggplot(aes(x = as.factor(year_name), y = value, group = interaction(group, category),
linetype = category, col = group, )) + geom_line(lwd = 1) + theme_minimal() +
theme(axis.text.x = element_text(angle = 75, vjust = 0, hjust = 0)) + facet_wrap(vars(cat)) +
labs(title = "C.difficile Infection by Year", y = "Case rates (cases per 100,000)",
x = "Year")dat_mdrgn <- read.csv("/Users/mattz/Documents/GitHub/shea24_demo/HAICViz_-_MuGSI_20240330.csv") %>%
janitor::clean_names() %>%
mutate(keep = case_when(viewby == "Organism" & series != "All cases" ~ 1, organism ==
"CRAB" & viewby == "All cases" & topic == "Case Rates" ~ 1, TRUE ~ 0)) %>%
filter(keep == 1) %>%
mutate(series = ifelse(organism == "CRAB", "Acinetobacter baumanii", series))dat_mdrgn_plot <- dat_mdrgn %>%
ggplot(aes(x = as.factor(year_name), y = value, group = series)) + geom_line(aes(linetype = series)) +
theme(axis.text.x = element_text(angle = 75, vjust = 0, hjust = 0)) + labs(title = "Cases by year - Carbapenem-Resistant GNB",
y = "Cases per 1000 individuals", x = "Year") + gghighlight(series == "Acinetobacter baumanii") +
theme_minimal()respi <- read.csv("/Users/mattz/Documents/GitHub/shea24_demo/Outpatient_Respiratory_Illness_Activity_Map_20240401.csv") %>%
janitor::clean_names() %>%
mutate(region = tolower(state)) %>%
separate(activity_level, into = c(NA, "level"), sep = " ") %>%
mutate(level = as.numeric(level)) %>%
filter(season == "2022-2023")
states <- map_data("state")gif_a <- region_dat_respi %>%
ggplot(., aes(long, lat, group = group)) + geom_polygon(aes(fill = level), colour = alpha("white",
1/2), size = 0.05) + geom_polygon(data = states, colour = "black", fill = NA) +
scale_fill_gradientn(colours = terrain.colors(6)) + theme_void() + transition_time(week) +
labs(title = "Respiratory Infection Activity 22-23 Season: Week {frame_time}") +
theme_minimal()
gif_a <- animate(gif_a, width = 700, height = 480)gif_b <- region_dat_respi %>%
# filter(!is.na(value)) %>%
ggplot(data = ., aes(y = level)) + geom_boxplot() + labs(x = "", title = "National Value") +
theme(axis.text.x = element_blank()) + transition_time(week)
# enter_fade() + exit_shrink() + ease_aes('sine-in-out')
gif_b <- animate(gif_b, width = 600, height = 480)vaccination <- read.csv("/Users/mattz/Documents/GitHub/shea24_demo/Vaccination_Coverage_among_Health_Care_Personnel_20240401.csv") %>%
janitor::clean_names() %>%
mutate(year = as.numeric(substr(season, 1, 4))) %>%
mutate(region = tolower(geography)) %>%
left_join(latitude_by_states, by = "region") %>%
rename(latitude = mean_lat) %>%
filter(personnel_type != "All Health Care Personnel")| Characteristic | Beta | 95% CI1 | p-value |
|---|---|---|---|
| year | 1.2 | 0.96, 1.5 | <0.001 |
| latitude | 0.34 | 0.22, 0.47 | <0.001 |
| personnel_type | |||
| Adult Students/Trainees and Volunteers | — | — | |
| Employees | 3.2 | 1.7, 4.6 | <0.001 |
| Licensed Independent Practitioners | -14 | -16, -13 | <0.001 |
| 1 CI = Confidence Interval | |||